Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

refactor(*): remove workarounds for IE <9, log all parameters in IE 9 #15911

Merged
merged 3 commits into from
Apr 25, 2017

Conversation

mgol
Copy link
Member

@mgol mgol commented Apr 12, 2017

  1. Remove remanining workarounds for IE <9
  2. Log all parameters in IE 9, not just the first two.
  3. Update IE/Edge-related support comments.
  4. ES6 classes now require Edge 14 or newer to work.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
A refactor.

What is the current behavior? (You can also link to an open issue here)
Some code targeting IE <=8 still exists in the code base, support comments don't account for Edge 15.

What is the new behavior (if this is a feature change)?
The opposite. Also, $log is now able to log more than 2 parameters on IE and all browsers use one code path for passing parameters to a proper logging function.

Does this PR introduce a breaking change?
No, unless we consider breaking support for classes in Edge 13 (current version is 15) a breaking change.

Please check if the PR fulfills these requirements

Other information:

@mgol mgol self-assigned this Apr 12, 2017
@mgol mgol force-pushed the ie branch 3 times, most recently from 8ec4ae5 to ce05599 Compare April 12, 2017 13:42
@Narretz
Copy link
Contributor

Narretz commented Apr 13, 2017

I think this should be split into separate commits:

  • IE8 removal refactor
  • IE9 log change
  • Edge class change
  • doc changes

I think it's acceptable that we only support Edge 15 for classes, especially since current FF is still choking on them, too.

@mgol
Copy link
Member Author

mgol commented Apr 13, 2017 via email

@Narretz
Copy link
Contributor

Narretz commented Apr 13, 2017

3 commits sounds good - as long as the fixes have their own separate commits

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of nits. Looks good otherwise.
(:+1: for breaking up into separate commits.)

})
);
// Support: Safari 9.1 only, iOS 9.3 only
// For some reason Safar thinks there is always 1 parameter passed here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safar --> Safari

// For some reason Safar thinks there is always 1 parameter passed here.
if (!/\b9\.\d(\.\d+)* safari/i.test(window.navigator.userAgent) &&
!/\biphone os 9_/i.test(window.navigator.userAgent)) {
it('should not attempt to log the second argument in IE if it is not specified', inject(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in IE --> in ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is a little weird. It's supposed to simulate the IE logging behavior (i.e. missing apply on console methods). Normally we'd just run those tests in IE without patching them but to be able to mock those methods we have to replace them with mocks that are regular functions so, in turn, we have to delete the methods.

Is there any way to reduce the confusion here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After taking a look at the whole describe block, I think it's fine.
I think we could now have a test that all arguments are logged (not just the first two as used to happen).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gkalpak I think we may even want to wrap the whole file in this block removing apply to simulate IE to have two test blocks - one with apply and another one without it; just to make sure there is now no observable difference in logging behavior with regular parameters in IE & non-IE.

I could do this cleanup in a separate PR, I don't want to drag this one further.

error = function(arg1, arg2) { logger += 'error,' + arguments.length + ';'; };
debug = function(arg1, arg2) { logger += 'debug,' + arguments.length + ';'; };
},
removeApplyFunctionForIE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ForIE 😞

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing. I misinterpreted the change.
Please ignore 😁

@Narretz Narretz modified the milestone: 1.6.5 Apr 19, 2017
mgol added 2 commits April 22, 2017 15:31
IE 9 lacks apply on console methods but it's possible to borrow the apply
method from Function.prototype.
@mgol
Copy link
Member Author

mgol commented Apr 22, 2017

PR updated & split into 3 commits.

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor suggestion, but LGTM otherwise.

// For some reason Safar thinks there is always 1 parameter passed here.
if (!/\b9\.\d(\.\d+)* safari/i.test(window.navigator.userAgent) &&
!/\biphone os 9_/i.test(window.navigator.userAgent)) {
it('should not attempt to log the second argument in IE if it is not specified', inject(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After taking a look at the whole describe block, I think it's fine.
I think we could now have a test that all arguments are logged (not just the first two as used to happen).

Copy link
Contributor

@Narretz Narretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. How did you figure out which IE workarounds can be removed? Because many only say "In IE", without specifying a version

@mgol
Copy link
Member Author

mgol commented Apr 24, 2017

How did you figure out which IE workarounds can be removed?

I tested them all manually in various IE/Edge versions.

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems secure...

ES6 classes now require Edge 14 or newer to work.

Closes angular#15911
@mgol mgol merged commit 602fa69 into angular:master Apr 25, 2017
@mgol mgol deleted the ie branch April 25, 2017 19:33
mgol added a commit to mgol/angular.js that referenced this pull request May 19, 2017
In IE 9 console methods don't inherit from Function.prototype and, hence, don't
have apply. Until recently IE 9 logging in AngularJS was restricted to the
first 2 parameters but that changed as we could just reuse
Function.prototype.apply everywhere, creating one code path for all browsers.
Therefore, we can now run all tests in modes where apply exists on logging
methods and where it doesn't.

Ref angular#15911
Ref b277e3e
mgol added a commit to mgol/angular.js that referenced this pull request May 24, 2017
In IE 9 console methods don't inherit from Function.prototype and, hence, don't
have apply. Until recently IE 9 logging in AngularJS was restricted to the
first 2 parameters but that changed as we could just reuse
Function.prototype.apply everywhere, creating one code path for all browsers.
Therefore, we can now run all tests in modes where apply exists on logging
methods and where it doesn't.

Ref angular#15911
Ref b277e3e
mgol added a commit that referenced this pull request May 24, 2017
In IE 9 console methods don't inherit from Function.prototype and, hence, don't
have apply. Until recently IE 9 logging in AngularJS was restricted to the
first 2 parameters but that changed as we could just reuse
Function.prototype.apply everywhere, creating one code path for all browsers.
Therefore, we can now run all tests in modes where apply exists on logging
methods and where it doesn't.

Ref #15911
Ref b277e3e
Closes #15995
mgol added a commit that referenced this pull request May 24, 2017
In IE 9 console methods don't inherit from Function.prototype and, hence, don't
have apply. Until recently IE 9 logging in AngularJS was restricted to the
first 2 parameters but that changed as we could just reuse
Function.prototype.apply everywhere, creating one code path for all browsers.
Therefore, we can now run all tests in modes where apply exists on logging
methods and where it doesn't.

Ref #15911
Ref b277e3e
Closes #15995
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants